<?php
/*****************
文件上传
******************/
include("inc/head.php");

$form = $_GET['form'];
$input = $_GET['input'];

if($_POST['doPost'] == 'true')
{
	//public static function uploadFile($formEl, $saveDir, $allowType, $allowSize)
	$attr = date("Y/m/d");
	$res = uploadFile("userfile", IMG_ROOT."/".$attr, ".jpg,.bmp,.gif,.png,.css,.txt,.zip,.rar,.js,.flv,.csv", "2048000");
	if(eregi("^error",$res) || $res == "")
	{
		new ActionLog(array("LogType"=>"upload_err","Action"=>"$res,$input"));
		alert("error");
	}
	$res = $attr."/".$res;
	new ActionLog(array("LogType"=>"upload_success","Action"=>"$res,$input"));
	if($input)
	{
		echo "<script>if(typeof(window.opener.document.getElementById(\"link_$input\"))!='undefined'){window.opener.document.getElementById(\"img_$input\").src='".IMG_URL."/$res';}window.opener.document.getElementById(\"img_$input\").src='".IMG_URL."/$res';window.opener.document.getElementById(\"$input\").value='$res';alert('上传成功');window.close();</script>";
	}
	else
		echo $res;
}

?>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="doPost" value="true">
    <input type="hidden" name="MAX_FILE_SIZE" value="2048000" />
 <input name="userfile" type="file" />
    <input type="submit" value="Send File" />
</form>
<?php
include("inc/foot.php");
?>